// 非法字符检测
const _ = require("lodash");
const validBody = async (ctx, next) => {
    let body = _.toLower(JSON.stringify(ctx.request.body))
    let invalidStr = ['delete ', 'truncate ', 'alter ', 'drop ', 'update ', 'exec ']
    for (let i = 0; i < invalidStr.length; i++) {
        if(body.indexOf(invalidStr[i]) !== -1) {
            return ctx.err('包含禁用字符' + invalidStr[i])
        }
    }
    await next();
}

module.exports = validBody